| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 
 |     private val mPopTitle: PopupWindow by lazy {PopupWindow(initPopView()).apply {
 //            有了contentView后要先测量一下才能拿到正确的高度
 contentView.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED)
 width = ScreenUtils.getScreenWidth()
 height = contentView.measuredHeight
 isOutsideTouchable = true
 isFocusable = true
 setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.black_35)))
 setOnDismissListener {
 tvTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.arrow_down_white, 0)
 PopUtils.clearDim(mContext)
 }
 }
 }
 
 | 
在initPopView()返回了contentView之后,要先测量一下再设置宽高。
contentView的xml里全是wrap_content。
因为需要黑色背景,直接加载popupwindow上就行了setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.black_35)))